package com.sgb.kjwl.repository.impl;

import com.sgb.kjwl.model.api.ApiSource;
import com.sgb.kjwl.model.entity.MachineDetailEntity;
import com.sgb.kjwl.model.entity.MachineRentInEntity;
import com.sgb.kjwl.model.entity.ParentAreaEntity;
import com.sgb.kjwl.model.entity.lease.CarListEntity3;
import com.sgb.kjwl.model.entity.lease.MachineListEntity3;
import com.sgb.kjwl.model.entity.request.LeaseMachineFilterJson;
import com.sgb.kjwl.model.entity.request.MachineFilterJson3;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.swgk.core.base.model.entity.ListResponse;
import com.sgb.kjwl.repository.MachineRepertory;
import com.swgk.core.base.api.BaseApiSource;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.preference.BasePreferenceSource;

import java.util.List;

import io.reactivex.Observable;

public class MachineRepertoryImpl extends BaseRepertoryImpl implements MachineRepertory {

    private final ApiSource apiSource;

    public MachineRepertoryImpl(BaseApiSource apiSource, BasePreferenceSource preferenceSource) {
        super(apiSource, preferenceSource);
        this.apiSource = (ApiSource) apiSource;
    }

    @Override
    public Observable<BaseEntity<MachineDetailEntity>> getMachineDetail(String id) {
        return apiSource.getMachineDetail(id).compose(this.<BaseEntity<MachineDetailEntity>>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<MachineRentInEntity>> getMachineInDetail(String id) {
        return apiSource.getMachineInDetail(id).compose(this.<BaseEntity<MachineRentInEntity>>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMachineFilterType() {
        return apiSource.getMachineFilterType().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMachineFilterModel(String parentNo) {
        return apiSource.getMachineFilterModel(parentNo).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMachineFilterTime() {
        return apiSource.getMachineFilterTime().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<ParentAreaEntity<List<ParentAreaEntity>>>>> getMachineArea(int areacode) {
        return apiSource.getMachineArea(areacode).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMachineFilterSort() {
        return apiSource.getMachineFilterSort().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<ListResponse<List<MachineListEntity3>>>> getMachineList3(LeaseMachineFilterJson machineFilterJson3) {
        return apiSource.getMachineList3(machineFilterJson3).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getMachineFilterSpec(String id) {
        return apiSource.getMachineFilterSpec(id).compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getCarFilterType() {
        return apiSource.getCarFilterType().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getCarFilterBrand() {
        return apiSource.getCarFilterBrand().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<DictEntity3>>> getCarFilterMoney() {
        return apiSource.getCarFilterMoney().compose(rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<ListResponse<List<CarListEntity3>>>> getCarList3(MachineFilterJson3 machineFilterJson3) {
        return apiSource.getCarList3(machineFilterJson3).compose(rxSchedulerHelper());
    }
}
